<template>
  <div :class="['neu-rank-list',size]">
    <ul>
      <li 
        v-for="item,index in dataList" 
        :key="index"
        @click="handleItemClick(index)"
      >
        <i class="rank-num">{{index+1}}</i>
        <span :class="{'active':index===currentIndex}">
          <b>{{item.name}}</b>
          <b v-if="item.percent">
            <i 
              :class="[
                'iconfont',
                {
                  'icon-arrow':!item.percent.status
                },{
                  'icon-arrow-down':item.percent.status
              }]"
            ></i> 
            {{item.percent.value}}%
          </b>
          <b>{{item.value}}</b>
        </span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "rankList",
  props:["dataList","size","current"],
  data(){
    return {
      currentIndex:this.current
    }
  },
  methods:{
    handleItemClick(index){
      // console.log(index)
      this.currentIndex = index
    }
  }
}
</script>

<style lang="scss" scoped>
.neu-rank-list{
  width: 100%;
  height: 100%;
  ul{
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    
    li{
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      i.rank-num{
        display: block;
        width: 50px;
        height: 24px;
        border-radius: 2px;
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(to right, #66A6FF, #6BD6DD);
      }
      span{
        display: block;
        height: 24px;
        flex-grow: 1;
        display: flex;
        justify-content: space-around;
        align-items: center;
        margin-left: 10px;
        border: 1px solid rgba(102,196,255,.5);
        border-radius: 2px;
        b{
          font-size: 14px;
          i{
            font-size: 10px;
          }
        }
        &:hover,
        &.active{
          border-color: #00FFFF;
          box-shadow: 0 0 10px rgba(0, 255, 255, .5) inset;
        }
      }
      &:nth-child(1){
        i.rank-num{
          background: linear-gradient(to right, #c6282f, #89090e);
        }
      }
      &:nth-child(2){
        i.rank-num{
          background: linear-gradient(to right, #d87e2f, #955511);
        }
      }
      &:nth-child(3){
        i.rank-num{
          background: linear-gradient(to right, #e1a903, #ba941b);
        }
      }
    }
  }
  &.small{
    ul{
      li{
        i.rank-num{
          width: 30px;
        }
      }
    }
  }
}
</style>